﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using Telerik;
using Telerik.Web.UI;

namespace TelerikHelper
{
    [ToolboxData("<{0}:AdvancedRibbonBar runat=server></{0}:AdvancedRibbonBar>")]
    public class AdvancedRibbonBar : RadRibbonBar
    {
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);
            string css = "<link href=\"" + this.Page.ClientScript.GetWebResourceUrl(this.GetType(), "TelerikHelper.Content.RibbonRTL.css") + "\" type=\"text/css\" rel=\"stylesheet\" />";
            RadScriptManager.RegisterStartupScript(this,this.GetType(), "AdvancedRibbonBarCss", css, false);
        }



        protected override void Render(HtmlTextWriter writer)
        {
            writer.Write("<div class=\"rtlForRibbon\">");
            base.Render(writer);
            writer.Write("</div>");

            string script = @"if ($('#" + this.ClientID + @"').css('direction') == 'ltr') {
                    $('#" + this.ClientID + "').parent().removeClass('rtlForRibbon')}";
            RadScriptManager.RegisterStartupScript(this.Page,this.Page.GetType(), "AdvancedRibbonBar", script, true);
        }
    }
}

